package com.ubing.boot.notesforjava.test.NIO;

import javax.swing.plaf.synth.SynthEditorPaneUI;
import java.io.*;
import java.net.Socket;

/**
 * @ClassName : sokect_client
 * @Description : sokect_client
 * @Author : Xxxxx
 * @Date: 2023-03-24 15:26
 */
public class sokect_client {
    public static void main(String[] args) {
        try {
            Socket client = new Socket("127.0.0.1", 9090);
            client.setSendBufferSize(20);
            client.setTcpNoDelay(true);
            OutputStream out = client.getOutputStream();
            InputStream in = System.in;
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            while(true){
                String line = reader.readLine();
                if(line!=null){
                    byte[] bytes = line.getBytes();
                    out.write(bytes);
//                    for(byte b:bytes){
//                        out.write(b);
//                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
